(function (_super) {
    var CONFIG = {
        "1v1" : {
            startX : 0,
            endX : 120,
            type : 1
        },
        "2v2" : {
            startX : 835,
            endX : 730,
            type : 2
        }
    }
    function Entrance(mode) {
        Entrance.super(this);

        this.mode = mode;
        this.ani = null;
        this.btnStart = null;

        this.init(mode);
    }
    Laya.class(Entrance, "Com.Matching.Entrance", _super);
    var _proto = Entrance.prototype;
    _proto.destroy = function () {
        _super.prototype.destroy.call(this, true);

        this.ani = null;
        this.btnStart = null;
    }

    _proto.init = function () {
        this.setup();
        this.create();
    }
    _proto.setup = function () {
        this.size(500, 390);
        this.pos(CONFIG[this.mode].startX, 25);
        this.alpha = 0;
    }
    _proto.create = function () {
        var ani = utils.createSkeleton("res/matching_waiting/" + this.mode);
            ani.pos(this.width / 2, this.height / 2);
            ani.play(0, true);

        var btnStart = new Laya.Button("res/matching_waiting/btn_start.png", "");
            btnStart.stateNum = 1;
            btnStart.centerX = 0;
            btnStart.y = 380;
            btnStart.on(Laya.Event.CLICK, this, function () {
                ppt.io.emit({"cmd" : "pvp::wait", params : {"type" : CONFIG[this.mode].type}});
            });

        this.ani = ani;
        this.btnStart = btnStart;
        this.addChildren(ani, btnStart);
    }
    
    _proto.enter = function () {
        Laya.Tween.to(this, {x : CONFIG[this.mode].endX, alpha : 1}, 300, Laya.Ease.circIn);
    }
})(Laya.Sprite);